import request from '../../../request';
import { AxiosPromise } from 'axios';
import { TreeVO, TreeForm, TreeQuery } from './types';

/**
 * 查询测试树列表
 *
 * @param query
 *
 * @returns {*}
 */
export const listTree = (query?: TreeQuery): AxiosPromise<TreeVO[]> => {
  return request({
    url: '/test/tree/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询测试树详细
 *
 * @param id
 */
export const getTree = (id: string): AxiosPromise<TreeVO> => {
  return request({
    url: '/test/tree/' + id,
    method: 'get'
  });
};

/**
 * 新增测试树
 *
 * @param data
 */
export const addTree = (data: TreeForm) => {
  return request({
    url: '/test/tree',
    method: 'post',
    data: data
  });
};

/**
 * 修改测试树
 *
 * @param data
 */
export const updateTree = (data: TreeForm) => {
  return request({
    url: '/test/tree',
    method: 'put',
    data: data
  });
};

/**
 * 删除测试树
 *
 * @param id
 */
export const delTree = (id: string | number | Array<string | number>) => {
  return request({
    url: '/test/tree/' + id,
    method: 'delete'
  });
};
